package com.erp.module.oem

import android.content.Context
import com.erp.Interface.OnUserDataInterface
import com.erp.bean.DuizhangBean
import com.erp.bean.OemBean
import com.erp.pull.BasePullP
import com.erp.util.JsonUtil
import org.json.JSONException
import org.json.JSONObject

class IOemP (var list :MutableList<OemBean>, var V : OemContract.OemView, var context: Context) : BasePullP(), OemContract.OemP{


    var md = OemModel()
    var onums = ""
    init {
        PullV = V
    }

    override fun sousuo(sousuo: String) {
        this.onums = sousuo
        xiala()
    }

    override fun getData(page: Int, pagesize: Int, onUserDataInterface: OnUserDataInterface) {
        md.getOemList(context,page,pagesize,onums,onUserDataInterface)
    }

    override fun jsondata(data: String?) {
        if (data==null){
            return
        }
        try {
            val j = JSONObject(data)
            val js = JsonUtil.getjsvolue(j,"data")
            for (i in 0 until js.length()) {
                val bean = OemBean()
                val jo = js.get(i) as JSONObject
                bean.id = JsonUtil.getvolue(jo, "id")
                bean.acceptance_time = JsonUtil.getvolue(jo, "acceptance_time")
                bean.deliver_time_0 = JsonUtil.getvolue(jo, "deliver_time_0")
                bean.o_onum = JsonUtil.getvolue(jo, "o_onum")
                bean.o_plan_warehousing_time = JsonUtil.getvolue(jo, "o_plan_warehousing_time")
                bean.shop_name = JsonUtil.getvolue(jo, "shop_name")
                bean.ctime = JsonUtil.getvolue(jo, "ctime")
                list.add(bean)
            }
        } catch (e: JSONException) {
            e.printStackTrace()

        }
    }



    override fun listClean() {
        list.clear()
    }
}